Table. Functional Annotation Enrichments


In [1]:
import copy
import cPickle
import os
import subprocess

import cdpybio as cpb
import matplotlib as mpl
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
pd.options.mode.chained_assignment = None  # default='warn'
import pybedtools as pbt
import scipy.stats as stats
import seaborn as sns

import ciepy
import cardipspy as cpy

%matplotlib inline

dy_name = 'table_functional_annotation_enrichments'
    
outdir = os.path.join(ciepy.root, 'output', dy_name)
cpy.makedir(outdir)

private_outdir = os.path.join(ciepy.root, 'private_output', dy_name)
cpy.makedir(private_outdir)

import socket
if socket.gethostname() == 'fl-hn1' or socket.gethostname() == 'fl-hn2':
    dy = os.path.join(ciepy.root, 'sandbox', 'tmp', dy_name)
    cpy.makedir(dy)
    pbt.set_tempdir(dy)

In [2]:
fn = os.path.join(ciepy.root, 'output', 'figure_functional_annotation', 'roadmap_res.tsv')
roadmap_res = pd.read_table(fn, index_col=0)

fn = os.path.join(ciepy.root, 'output', 'figure_functional_annotation', 'encode_res.tsv')
encode_res = pd.read_table(fn, index_col=0)

fn = os.path.join(ciepy.root, 'output', 'figure_functional_annotation', 'tf_res.tsv')
tf_res = pd.read_table(fn, index_col=0)

In [3]:
writer = pd.ExcelWriter(os.path.join(outdir, 'functional_enrichments.xlsx'))
roadmap_res.to_excel(writer, 'roadmap_dhs')
encode_res.to_excel(writer, 'encode_dhs')
tf_res.to_excel(writer, 'encode_tf')
writer.save()